package com.dz.Incubator.controller;

import com.dz.Incubator.entity.InvokeResult;
import com.dz.Incubator.entity.ServiceTypeEntity;
import com.dz.Incubator.service.ServiceTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author YM
 * @note
 * @date 2020/4/28
 */
@RestController
@RequestMapping("/api/a/serviceType")
public class ServiceTypeController {

    @Autowired
    private ServiceTypeService serviceTypeService;

    @RequestMapping(value = "insert", method = RequestMethod.POST)
    public InvokeResult<String> insert(@RequestBody ServiceTypeEntity serviceType) {
        serviceTypeService.insert(serviceType);
        return InvokeResult.success("添加成功");
    }

    ;

    @RequestMapping(value = "delete/{id}", method = RequestMethod.GET)
    public InvokeResult<String> delete(@PathVariable int id) {
        serviceTypeService.delete(id);
        return InvokeResult.success("删除成功");
    }

    @RequestMapping(value = "update", method = RequestMethod.POST)
    public InvokeResult<String> udpate(@RequestBody ServiceTypeEntity serviceTypeEntity) {
        serviceTypeService.udpate(serviceTypeEntity);
        return InvokeResult.success("修改成功");
    }

    @RequestMapping(value = "getAll", method = RequestMethod.GET)
    public InvokeResult<List<ServiceTypeEntity>> getAll() {
        return InvokeResult.success(serviceTypeService.getAll());
    }


    @RequestMapping(value = "getAllAndChild", method = RequestMethod.GET)
    public InvokeResult<List<ServiceTypeEntity>> getAllAndChild() {
        return InvokeResult.success(serviceTypeService.getAllAndChild());
    }

}
